
package harlequin;

import java.sql.*;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import javax.swing.*;

public class GeneralShow extends JFrame{
    
    public List<String> Title;
    public List<String> dateTimeslot;
    public List<Float> Price;
    public List<Integer> Slot;
    public List<Integer> AudienceCount;
    
    public String tempDate;
    public int setter;
    
    public String data[][] = {};
    public String col[] = {"Title", "Date-Timeslot", "Price", "Slot", "Audience Count"};
    public Connection connector;
    public  DefaultTableModel showmodel;
    public DefaultTableModel sectionmodel;
    public  int nRows = 0;
    
public void initializeShowList(){
      try {
        Statement stmt = connector.createStatement();
       ResultSet rs = stmt.executeQuery("Select * from play");
       while(rs.next()){
           Title.add(rs.getString("title"));
           dateTimeslot.add(rs.getString("dateTimeslot"));
           Price.add(rs.getFloat("price"));
           Slot.add(rs.getInt("slot"));
           AudienceCount.add(rs.getInt("audienceCount"));

       }
        } catch (SQLException ex) {
            Logger.getLogger(GeneralShow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
   public boolean InvalidDate(String tempDate) throws SQLException{
   
   String query = "select * from play";
   PreparedStatement preparedStatement = connector.prepareStatement(query);
   ResultSet set = preparedStatement.executeQuery(query);
    
    
    while(set.next()){
        if(set.getString("date").equals(tempDate)) 
            return true;
    }
    
    return false;
    }   
   
}
